

def gen_dsc_csv(save_path):
    train_csv_path = r'../data/track1_round1_train_20210222.csv'
    test_csv_path = r'../data/track1_round1_testA_20210222.csv'
    val_csv_path = r'../data/track1_round1_val_20210222.csv'

    rpt_data_list = []
    for csv_path in [train_csv_path,test_csv_path,val_csv_path]:
        with open(csv_path) as file:
            for line in file:
                groups = line.strip().split('|,|')
                report_id = groups[0]
                description = groups[1]
                rpt_data_list.append(description)

    with open(save_path,'w') as file:
        for line in rpt_data_list:
            file.write(line)
            file.write('\n')

save_path = r'../data/track1_description.csv'
gen_dsc_csv(save_path)
import fasttext

model = fasttext.train_unsupervised(save_path, model='skipgram')

print(model.words)
model.save_model(save_path.replace('.csv','.bin'))
